<template>
	<view class="home">
		<swiper indicator-dots circular>
			<swiper-item v-for="i in lunbo" :key="i.id">
				<image mode="aspectFit" :src="i.url" alt="">
			</swiper-item>
		</swiper>

		<view class="nav">
			<view class="nav_item">
				<view class="iconfont icon-ziyuan" @click="turn('/pages/goods/goods')">
				</view>
				<text>app超市</text>
			</view>
			<view class="nav_item">
				<view class="iconfont icon-guanyuwomen" @click="turn('/pages/contact/contact')">
				</view>
				<text>联系我们</text>
			</view>
			<view class="nav_item">
				<view class="iconfont icon-tupian" @click="turn('/pages/pics/pics')">
				</view>
				<text>社区图片</text>
			</view>
			<view class="nav_item">
				<view class="iconfont icon-shipin" @click="turn('/pages/video/video')">
				</view>
				<text>学习视频</text>
			</view>
		</view>
		<view class="hot">
			<view class="tit">
				热销商品
			</view>
			<goodsList :list="list" @navto="navto"></goodsList>
		</view>


	</view>
</template>

<script>
	import goodsList from "../../components/goodsList.vue"
	export default {
		data() {
			return {
				lunbo: [],
				list:[],
			}
		},

		components: {
			goodsList
		},



		onLoad() {
			this.getLunbo()
			this.getList()
		},
		methods: {
			async getLunbo() {
				let result = await this.$myRequest({
					url: '/api/getlunbo'
				})
				this.lunbo = result.data.message

			},
			async getList() {
				let res = await this.$myRequest({
					url: "/api/getgoods?pageindex=1" 
				})
				this.list = [...this.list, ...res.data.message]
			},

			turn(url) {
				uni.navigateTo({
					url
				})
			},
			navto(id){
				uni.navigateTo({
					url:"../goodsdetail/goodsdetail?id="+id
				})
			}
			
		}
	}
</script>

<style scoped lang="scss">
	.home {
		swiper {
			height: 380rpx;
			width: 750rpx;

			image {
				height: 100%;
				width: 100%;
			}
		}
	}

	.nav {
		display: flex;

		.nav_item {
			width: 25%;
			text-align: center;

			view {
				width: 120rpx;
				height: 120rpx;
				background: $index_color;
				border-radius: 60rpx;
				margin: 10px auto;
				line-height: 120rpx;
				color: #fff;
				font-size: 50rpx;

			}

			text {
				font-size: 30rpx;
			}
		}
	}

	.hot {
		background: #eee;
		overflow: hidden;
		margin-top: 10px;

		.tit {
			margin: 10px 0;
			height: 50px;
			background: white;
			line-height: 50px;
			letter-spacing: 10px;
			text-align: center;
			color: $index_color;
		}

	}
</style>
